import 'package:vista/shared/models/base_frame.dart';
import 'package:vista/shared/models/photo_params.dart';

/// 每日灵感画面
/// 存储每日灵感信息，如摄影中的灵感瞬间般记录创作启发
class DailyInspiration extends BaseFrame {
  final String id; // 灵感ID
  final String authorId; // 发布者ID
  final String title; // 标题
  final String description; // 详情
  final String image; // 图片
  final PhotoParams photoParams; // 摄影参数
  final DateTime timestamp; // 发布时间

  const DailyInspiration({
    required this.id,
    required this.authorId,
    required this.title,
    required this.description,
    required this.image,
    required this.photoParams,
    required this.timestamp,
  });

  /// 从JSON创建每日灵感画面
  factory DailyInspiration.fromJson(Map<String, dynamic> json) {
    return DailyInspiration(
      id: json['id'] as String,
      authorId: json['authorId'] as String,
      title: json['title'] as String? ?? '',
      description: json['description'] as String? ?? '',
      image: json['image'] as String,
      photoParams: PhotoParams.fromJson(
        json['photoParams'] as Map<String, dynamic>,
      ),
      timestamp: DateTime.parse(json['timestamp'] as String),
    );
  }

  @override
  List<Object?> get props => [
    id,
    authorId,
    title,
    description,
    image,
    photoParams,
    timestamp,
  ];

  @override
  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'authorId': authorId,
      'title': title,
      'description': description,
      'image': image,
      'photoParams': photoParams.toJson(),
      'timestamp': timestamp.toIso8601String(),
    };
  }
}
